JSON
JSON
is an object with methods for parsing and converting.
There are only two methods JSON
uses.
info
JSON
- JavaScript Object Notation
Hedgehog Script supports JavaScript
note
JavaScript is not JSON
There are certain things that are required for objects
s & Array
s in JSON
:
One must double quote property names
Trailing commas and leading zeros are forbidden
Note that
NaN
andInfinity
aren't supported
Let's start with an example of one of the two methods: stringify()
Note that one can also embed or nest JSON
:
tip
Use JSON.stringify()
to convert certain objects into strings
The mentioned methods are: JSON.parse()
and JSON.stringify
(both static
).
The effective difference is parse transforms the string into JSON
while stringify returns a JSON
string.
info
Both methods have replacer
and reviver
as option fields.
reviver
allows for interpreting what replacer
has replaced
Let's have a demo of JSON.parse()
& JSON.stringify()
:
Here's an example using the mentioned reviver
and replacer
options:
info
JSON
can be an in-depth topic - this is only an introduction.
Check out the MDN page for JSON
here: JSON-MDN docs